/**
 * author: zhangwei
 * 角色新增、编辑
 */
var pageType = "add";
var main = {

    init: function() {
        this.id = localStorage.id;

        loadData(this.id);
        this.initTable();
    },
    initTable: function() {
        $("#submit").click(function () {
            id = $("#id").val()
            replay = $("#replay").val()
            $.ajax({
                type:"get",
                async:false,
                url:'/userRemark/saveReplay?id='+id+"&replay="+replay,
                success:function(result) {
                    if (result.code == property.successCode) {
                        successMsg("保存成功")
                    } else{
                        errorMsg(result.msg);
                    }
                },
                error:function(result) {
                    errorMsg("系统异常");
                }
            });
        })

    },
    getDetailData: function() {
        layui.use('form', function() {
            var form = layui.form;
            form.val("myform", {
                "title": "贤心"
                ,"name": "vvvvv"
                ,"city": "1"  // 下拉框初始赋值
                ,"desc": "我爱layui"
            });
        });
    }
}
main.init();

/**
 * 加载表单数据
 * @param id 角色id
 */
function loadData(id) {
    $("#id").val(id)
    data = []
    $.ajax({
        type:"get",
        async:false,
        url:'/userRemark/getDetailInfo?id='+id,
        success:function(result) {
            if (result.code == property.successCode) {
                data =result.data
            } else{
                errorMsg(result.msg);
            }
        },
        error:function(result) {
            errorMsg("系统异常");
        }
    });

    $("#id").val(data.id)
    $("#content").text(data.content)
    htmlstr=""
    doctorReplayDtoList = data.doctorReplayDtoList
    for(i=0;i<doctorReplayDtoList.length;i++){
        doctorReplayDto = doctorReplayDtoList[i];
        itemstr = "<li><p><a  target=\"_blank\" class='liname'>"+doctorReplayDto.doctorName+"</a><span class='litime'>"+
            formatDate(doctorReplayDto.createTime)+"</span>&nbsp;</p><span class=\"ir-content\">"+
            doctorReplayDto.replay+"</span></li>"
        htmlstr = htmlstr+itemstr
    }
    $("#ir-list").html(htmlstr)
}

/**
 * 设置表单数据
 * @param data
 */
function setFormData(data) {
    property.setForm($("#roleForm"),data);

}



